package com.gec.system.exception;

import com.gec.system.util.Result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.expression.AccessException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ControllerAdvice
public class MyCustomException extends RuntimeException {
    private Integer code;
    private String msg;
    @ExceptionHandler(AccessException.class)
    @ResponseBody
    public Result error(MyCustomException e){
    e.printStackTrace();
    return Result.fail().message(e.getMsg()).code(e.getCode());
    }
}
